﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace snat.algorithms.node.TFIDF {
    public class TF {

        //MID, word, score
        private Dictionary<int, Dictionary<String, double>> score;
        public double this[int mid, String s] {
            get {
                return score[mid][s];
            }
            set {
                score[mid][s] = score[mid].ContainsKey(s) ? score[mid][s] + value : value;
            }
        }

        public int wordsInDoc { get; private set; }

        public TF(Dictionary<String, int> _words, int _wordsInDoc) {
            this.score = new Dictionary<String, double>();
            this.wordsInDoc = _wordsInDoc;
            foreach (String word in _words.Keys) {
                this.score[word] = _words[word] / (double)wordsInDoc;
            }
        }
    }
}
